//
//  Item.m
//  MyFunctionDemo
//
//  Created by Ting Han on 2017/9/21.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "Item.h"
#import "AttributedStringConfigHelper.h"

@interface Item ()

@property (nonatomic,strong) NSMutableAttributedString *attrName;

@end

@implementation Item
+ (instancetype)itemWithName:(NSString *)name data:(id)data{
    Item *item = [[self class]new];
    item.name = name;
    item.data = data;
    return item;
}
- (void)createAttributedString{
    NSString *full = [NSString stringWithFormat:@"%02ld. %@", (long)self.index, self.name];
    NSMutableAttributedString *att = [NSMutableAttributedString mutableAttributedStringWithString:full config:^(NSString *string, NSMutableArray<AttributedStringConfig *> *configs) {
        [configs addObject:[FontAttributeConfig configWithFont:[UIFont fontWithName:@"Heiti SC" size:16.f] range:NSMakeRange(0, string.length)]];
        [configs addObject:[FontAttributeConfig configWithFont:[UIFont fontWithName:@"GillSans-Italic" size:16.f] range:NSMakeRange(0, 3)]];
        [configs addObject:[ForegroundColorAttributeConfig configWithColor:[[UIColor blackColor] colorWithAlphaComponent:0.65f] range:NSMakeRange(0, string.length)]];
        [configs addObject:[ForegroundColorAttributeConfig configWithColor:[[UIColor redColor] colorWithAlphaComponent:0.65f] range:NSMakeRange(0, 3)]];
        
    }];
    self.attrName = att;
}
@end
